﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Infrastructure.Library
{
    /// <summary>
    /// The action performed by the save event.
    /// </summary>
    public enum SaveAction
    {
        /// <summary>
        ///     Default. Nothing happened.
        /// </summary>
        None,

        /// <summary>
        ///     It's a new object that has been inserted.
        /// </summary>
        Insert,

        /// <summary>
        ///     It's an old object that has been updated.
        /// </summary>
        Update,

        /// <summary>
        ///     The object was deleted.
        /// </summary>
        Delete
    }

    /// <summary>
    /// The saved event args.
    /// </summary>
    public class SaveEventArgs : EventArgs
    {
        #region Properties

        /// <summary>
        /// Gets or sets the action that occured when the object was saved.
        /// </summary>
        public SaveAction Action { get; set; }
        public Object SaveObj { get; set; }

        #endregion

        #region Constructors and Destructors
        /// <summary>
        /// Initializes a new instance of the <see cref="SavedEventArgs"/> class.
        /// </summary>
        /// <param name="action">
        /// The action.
        /// </param>
        public SaveEventArgs(SaveAction action)
        {
            this.Action = action;
        }

        #endregion

        public override string ToString()
        {
            return String.Format("Action={0} SaveObj={1}", Action.ToString(), SaveObj.ToString());
        }
    }
    /// <summary>
    /// BrokerCD Back up
    /// </summary>
    [Serializable]
    public class RMTEventArg : EventArgs
    {
        public string Topic;
        public string Key;
        public string Operator;
        public object OldValue;
        public object NewValue;

        public RMTEventArg(String topic) : this(topic, "") { }

        public RMTEventArg(String topic, String key) : this(topic, key, "", null, null) { }

        public RMTEventArg(String topic, String key, String opt, object oldVal, object newVal)
        {
            this.Topic = topic;
            this.Key = key;
            this.Operator = opt;
            this.OldValue = oldVal;
            this.NewValue = newVal;
        }

        public override string ToString()
        {
            return String.Format("Topic={0} Key={1} Operator={2} OldValue={3} NewValue={4}", Topic, Key, Operator, OldValue, NewValue);
        }
    }
}
